//ACCEPTED
#include <cstdio>

int n, d, v[1000], sum;

void read(){
	scanf("%d %d", &n, &d);
	for(int i=0;i<n;i++){
		scanf("%d", &v[i]);
	}
}
void process(){
	int i, j, mod;
	sum = 0;
	for(i=0;i<n;i++)
		for(j=i+1;j<n;j++){
			mod = v[i]-v[j];
			if(mod<0)mod*=-1;
			if(mod<=d)sum+=2;
		}
}

int main(){
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	
	read();
	process();
	
	printf("%d", sum);
	
	return 0;
}
